<template>
  <div>
    <h1>用户登录注册测试</h1>
    <button @click="handleReg">注册</button>
    <button @click="handleLog">登录</button>
    <h2>{{ msg }}</h2>
  </div>
</template>

<script>
import { userRequest } from "@/network/request";
export default {
  name: "Test",
  data() {
    return {
      msg: "",
    };
  },
  methods: {
    handleReg(e) {
      userRequest({
        url: "/reg",
        method: "post",
        data: {
          userName: "用户名11",
          password: "密码112233",
          nickName: "昵称",
          avatar:
            "https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20191215%2F6dfdfe014daa456aaf12453b1e0bb65e.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624947813&t=8556c738b2e05c2abf9691c9de0e5e4e",
        },
      }).then((res) => {
        console.log(res);
        if (res.code === "success") {
          console.log("登录成功");
        } else {
          console.log("登录失败");
        }
      });
    },
    handleLog(e) {
      userRequest({
        url: "/login",
        method: "post",
        data: {
          userName: "用户名11111",
          password: "密码11",
        },
      }).then((res) => {
        console.log(res);
        if (res.code === "success") {
          console.log("登录成功");
        } else {
          console.log("登录失败");
        }
      });
    },
  },
};
</script>

<style>
</style>